{include file='public/header' /}


<body>

    <div class="layui-fluid">

        <div class="layui-row">

            <form class="layui-form " enctype="multipart/form-data" id="file" style="margin: 50px;">


                <div class="layui-form-item">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">

                            *

                        </span>

                        Topic

                    </label>

                    <div class="layui-input-block ">

                        <input autocomplete="off" class="layui-input" id="topic" lay-verify="required" name="topic" placeholder="请输入Topic" required="" type="text">
                    </div>

                </div>



                 <div class="layui-form-item">
                          <label for="phone" class="layui-form-label">
                            <span class="x-red">

                            *

                            </span>
                              数据内容
                          </label>
                           <div class="layui-input-block">
                            <textarea placeholder="请输入数据内容" class="layui-textarea" name="content"></textarea>
                          </div>
                  </div>


              
                <div class="layui-form-item" style="margin-top: 50px;">

                    <label class="layui-form-label" for="L_repass">

                    </label>

                    <button class="layui-btn" id="submitBtn" lay-filter="add" lay-submit="" type="submit">

                        添加测试数据

                    </button>

                </div>

            </form>

        </div>

    </div>






    <script>

        layui.use(['form', 'layer'],

    function() {

        $ = layui.jquery;

        var form = layui.form,

        layer = layui.layer;


    });

    </script>




    <script>

    layui.config({
        base: '__ROOT__/static/admin/lib/layui/lay/modules/',
    })
    // 只需要引入multiSelect模块即可
    layui.use(['multiSelect'],function() {
        
    });
        //获取form表单的节点

  fileEle = document.getElementById('file');

  arr = [];

  //把value的值拿出来

  valEle = '';

  nulEle = '';





  $("#file").on("submit",function(){

   

    //阻止form默认提交

    var evt = event;

    evt.preventDefault();

    //得到formData

    var formData = new FormData($(this)[0]);


    $.ajax({

      url:"{:url('Ceshi/add')}",

      type:"post",

      async: false,

      cache: false,

      contentType: false,

      processData: false,

      data:formData,

      success:function(data){


        if (data == 1) {

            layer.msg('添加成功', {icon: 1,time: 1500});

            setTimeout(function(){
              //刷新父页面
              window.parent.location.reload(); 
              // 获得frame索引
              var index = parent.layer.getFrameIndex(window.name); 
              //关闭当前frame
              parent.layer.close(index);

            },1500);

        }else if(data == 2){

            layer.msg('添加失败,请完善全部信息！', {icon: 2,time: 1500});

        }else{

            layer.msg('添加失败', {icon: 2,time: 1500});


        }

        

      }

    })

  })

    </script>

</body>

